# 单例模式
from abc import ABCMeta, abstractmethod
class Singleton(metaclass=ABCMeta):
    _instance = None
    @abstractmethod
    def __init__(self):
        pass
    @classmethod
    def instance(cls):
        if cls._instance is None:
            cls._instance = cls()
        return cls._instance

class MyClass(Singleton):
    def __init__(self):
        pass

if __name__ == "__main__":
    obj1 = MyClass.instance()
    obj2 = MyClass.instance()
    print(obj1 is obj2) # True  